# matrix prod example
import numpy as np
import matplotlib.pyplot as plt

N = 20 # 指定窗口大小

# 生成窗权重数列
# hanning_window = np.array([0.5 - 0.5 * np.cos(2 * np.pi * n / (N - 1)) for n in range(N)])
window_weights = np.hanning(N)

# 生成原始输入信号
# input_signals = np.array([0.5 + 0.5 * np.cos(2 * np.pi * n / 10) for n in range (N)])
input_signals = np.array([0.01 * n for n in range (N)])


# 加窗
output_signals = input_signals * window_weights

# 打印输入输出信号数列
print('input_signals: \n', input_signals)
print('window_weights:\n', window_weights)
print('output_signals:\n', output_signals)

# 显示曲线
plt.figure()
plt.subplot(1, 2, 1)
plt.plot(input_signals)
plt.subplot(1, 2, 2)
plt.plot(output_signals)
plt.show()

